﻿
namespace sinetd.Protocols
{
    /// <summary>
    /// Represents the method that will handle new connection.
    /// </summary>
    /// <param name="prot">The instance of protocol from new connection.</param>
    public delegate void AcceptClientHandler(IProtocol protocol);

    /// <summary>
    /// Provides functionality required by sinetd.Server from all protocols.
    /// </summary>
    public interface IProtocol : IManagerElement, IConnectionIO
    {
        /// <summary>
        /// Associates a instance which implement sinetd.Protocols.IProtocol with a provided by end point.
        /// </summary>
        /// <param name="AcceptClient">A sinetd.Protocols.AcceptClientHandler delegate that represents the method to be invoked on new connection.</param>
        void Bind(AcceptClientHandler AcceptClient);
        /// <summary>
        /// Opens the sinetd.Protocols.IProtocol connection.
        /// </summary>
        /// <returns>Returns true if connected with successfull, otherwise returns false.</returns>
        bool Connect();
        /// <summary>
        /// Closes the sinetd.Protocols.IProtocol connection and releases all associated resources.
        /// </summary>
        void Close();
    }
}
